# 初始化用户
from app.db.session import get_db
from sqlalchemy.orm import Session
from app.core import security

db: Session = next(get_db())
from app.models.user import User
from app.schemas.user import UserCreate

user_in = UserCreate(username='admin', email="xxx@qq.com", password="123456",nickname="AI程序员")

user = db.query(User).filter(User.username == user_in.username).first()
#更新用户信息
if user:
    user.hashed_password=security.get_password_hash(user_in.password)
    user.email=user_in.email
    user.nickname=user_in.username
    db.add(user)
    db.commit()
    db.refresh(user)
db.close()
